<?php
namespace common\models;

use yii\behaviors\TimestampBehavior;
use yii\db\ActiveRecord;

/**
 * 收款信息模型
 * @author WJ
 */
class ARWallet extends ActiveRecord
{

    const TYPE_BANK = 1; //网银
    const TYPE_ZFB = 2; //支付宝
    const TYPE_OTHER = 99; //其他

    public static $type = [
        self::TYPE_BANK => '网银转账',
        self::TYPE_ZFB  => '支付宝',
    ];

    const DEFAULT_IS = 1;
    const DEFAULT_NOT = -1;

    const DELETE_NOT = 1;
    const DELETE_IS = -1;

    const SECURITY_SAFE = 1; //数据安全
    const SECURITY_UNSAFE = 0; //数据不安全

    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%wallet}}';
    }

    /**
     * @inheritdoc
     */
    public function behaviors()
    {
        return [
            TimestampBehavior::className(),
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'uid'           => '用户编号',
            'type'          => '账户类型',
            'other_type'    => '其他收款方式',
            'bank'          => '银行',
            'account'       => '账号',
            'account_name'  => '账户名称',
            'describe'      => '账户描述',
            'name'          => '别名',
            'is_default'    => '是否默认',
            'security_code' => '安全码',
            'security_at'   => '安全时间',
        ];
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['type', 'other_type', 'bank', 'account', 'account_name', 'describe', 'name', 'is_default', 'security_code', 'security_at'], 'safe'],
        ];
    }
}
